import java.util.concurrent.TimeUnit;

public class Main3 {
  public static void main(String[] args) throws Exception {
    //
    Result a = new Result("");
    Productor p = new Productor();
    p.setA(a);
    p.start();

    synchronized (a) {
      a.wait();
      System.out.println(a.getResultHolder());
    }
  }

  static class Productor extends Thread {
    Result a;

    public void setA(Result a) {
      this.a = a;
    }

    @Override
    public void run() {
      synchronized (a) {
        try {
          TimeUnit.MILLISECONDS.sleep(1000);

        } catch (InterruptedException e) {
          e.printStackTrace();
        }
        a.setResultHolder("我是结果");
        a.notify();
      }
    }
  }

  static class Result {
    public String resultHolder;

    public Result(String result) {
      this.resultHolder = result;
    }

    public void setResultHolder(String result) {
      resultHolder = result;
    }

    public String getResultHolder() {
      return resultHolder;
    }
  }
}
